/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tecbooks;

import javax.swing.JOptionPane;

/**
 *
 * @author Taciane
 */
public class CadastroAcervo extends javax.swing.JFrame {

    /**
     * Creates new form CadastroAcervo
     */
    public CadastroAcervo() {
        setTitle("Cadastro de acervo");
        initComponents();
    }

 
    
        @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        lblNomeLivro = new javax.swing.JLabel();
        lblAutorLivro = new javax.swing.JLabel();
        lblGeneroLivro = new javax.swing.JLabel();
        lblAnoLivro = new javax.swing.JLabel();
        lblSinopseLivro = new javax.swing.JLabel();
        lblEditoraLivro = new javax.swing.JLabel();
        txtNomeLivro = new javax.swing.JTextField();
        txtAutorLivro = new javax.swing.JTextField();
        cmbGeneroLivro = new javax.swing.JComboBox();
        txtEditoraLivro = new javax.swing.JTextField();
        txtAnoLivro = new javax.swing.JFormattedTextField();
        jScrollPane2 = new javax.swing.JScrollPane();
        sinopseLivro = new javax.swing.JEditorPane();
        btnOkLivro = new javax.swing.JButton();
        btnLimparAcervo = new javax.swing.JButton();
        btnCancelarAcervo = new javax.swing.JButton();
        lblAcervoAviso = new javax.swing.JLabel();
        lblIdLivroAcervo = new javax.swing.JLabel();
        idLivroAcervo = new javax.swing.JFormattedTextField();
        lblAvisoIdLivro = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        lblNomeLivro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblNomeLivro.setForeground(new java.awt.Color(0, 0, 255));
        lblNomeLivro.setText("Nome*:");
        getContentPane().add(lblNomeLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 89, -1, -1));

        lblAutorLivro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblAutorLivro.setForeground(new java.awt.Color(0, 0, 255));
        lblAutorLivro.setText("Autor*:");
        getContentPane().add(lblAutorLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 127, -1, -1));

        lblGeneroLivro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblGeneroLivro.setForeground(new java.awt.Color(0, 0, 255));
        lblGeneroLivro.setText("Gênero*:");
        getContentPane().add(lblGeneroLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 160, -1, -1));

        lblAnoLivro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblAnoLivro.setForeground(new java.awt.Color(0, 0, 255));
        lblAnoLivro.setText("Ano de lançamento:");
        getContentPane().add(lblAnoLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 240, -1, -1));

        lblSinopseLivro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblSinopseLivro.setForeground(new java.awt.Color(0, 0, 255));
        lblSinopseLivro.setText("Sinopse:");
        getContentPane().add(lblSinopseLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 280, -1, -1));

        lblEditoraLivro.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblEditoraLivro.setForeground(new java.awt.Color(0, 0, 255));
        lblEditoraLivro.setText("Editora*:");
        getContentPane().add(lblEditoraLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 200, -1, -1));
        getContentPane().add(txtNomeLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 80, 270, -1));
        getContentPane().add(txtAutorLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(60, 120, 270, -1));

        cmbGeneroLivro.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "      ", "Romance", "Terror", "Suspence", "Romance herótico", "Infantil", "Infanto-juvenil", "Mitologia", "Auto-Ajuda", "Ciência", "Culinária", "Ficção", "Filosofia", "História", "Lingüistica", "Lit. Estrangeira", "Lit. Nacional", "Medicina", "Música", "Política", "Psicologia", "Quadrinhos", "Religião", "Terror", "Crônica", "Poesia", "Poemas" }));
        getContentPane().add(cmbGeneroLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 160, 143, -1));
        getContentPane().add(txtEditoraLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 200, 263, -1));

        try {
            txtAnoLivro.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        txtAnoLivro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                txtAnoLivroActionPerformed(evt);
            }
        });
        getContentPane().add(txtAnoLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(140, 240, 80, -1));

        jScrollPane2.setViewportView(sinopseLivro);

        getContentPane().add(jScrollPane2, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 310, 260, 119));

        btnOkLivro.setText("OK");
        btnOkLivro.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnOkLivroActionPerformed(evt);
            }
        });
        getContentPane().add(btnOkLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 450, -1, -1));

        btnLimparAcervo.setText("Limpar");
        btnLimparAcervo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnLimparAcervoActionPerformed(evt);
            }
        });
        getContentPane().add(btnLimparAcervo, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 450, -1, -1));

        btnCancelarAcervo.setText("Cancelar");
        btnCancelarAcervo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCancelarAcervoActionPerformed(evt);
            }
        });
        getContentPane().add(btnCancelarAcervo, new org.netbeans.lib.awtextra.AbsoluteConstraints(210, 450, -1, -1));

        lblAcervoAviso.setFont(new java.awt.Font("Tahoma", 1, 18)); // NOI18N
        lblAcervoAviso.setForeground(new java.awt.Color(239, 10, 10));
        getContentPane().add(lblAcervoAviso, new org.netbeans.lib.awtextra.AbsoluteConstraints(17, 490, 330, 40));

        lblIdLivroAcervo.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        lblIdLivroAcervo.setForeground(new java.awt.Color(0, 0, 255));
        lblIdLivroAcervo.setText("ID*:");
        getContentPane().add(lblIdLivroAcervo, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 28, -1, -1));

        idLivroAcervo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                idLivroAcervoActionPerformed(evt);
            }
        });
        getContentPane().add(idLivroAcervo, new org.netbeans.lib.awtextra.AbsoluteConstraints(37, 25, 113, -1));
        getContentPane().add(lblAvisoIdLivro, new org.netbeans.lib.awtextra.AbsoluteConstraints(37, 54, 280, 21));

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/tecbooks/CadasroAcervo.jpg"))); // NOI18N
        getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(4, -1, 360, 550));

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void btnOkLivroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkLivroActionPerformed
        if(txtNomeLivro.getText().isEmpty() ||idLivroAcervo.getText().isEmpty() || txtEditoraLivro.getText().isEmpty() || txtAutorLivro.getText().isEmpty()|| cmbGeneroLivro.getSelectedItem().equals("  ")){
            lblAcervoAviso.setText("Preencha os campos obrigatórios!");
        }
        else{
            JOptionPane.showMessageDialog(null, "Cadastro de acervo realizado com sucesso!");
            dispose();
            TelaPrincipal tela = new TelaPrincipal();
            tela.setVisible(true);
        }       
    }//GEN-LAST:event_btnOkLivroActionPerformed

    private void txtAnoLivroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtAnoLivroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_txtAnoLivroActionPerformed
    
    private void idLivroAcervoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_idLivroAcervoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_idLivroAcervoActionPerformed

    private void btnLimparAcervoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLimparAcervoActionPerformed
        idLivroAcervo.setText("");
        txtNomeLivro.setText("");
        txtAutorLivro.setText("");
        txtEditoraLivro.setText("");
        txtAnoLivro.setText("");
        sinopseLivro.setText("");
        cmbGeneroLivro.setSelectedIndex(0);
    }//GEN-LAST:event_btnLimparAcervoActionPerformed

    private void btnCancelarAcervoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelarAcervoActionPerformed
        dispose();
        TelaPrincipal tela = new TelaPrincipal();
        tela.setVisible(true);        // TODO add your handling code here:
    }//GEN-LAST:event_btnCancelarAcervoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CadastroAcervo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CadastroAcervo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CadastroAcervo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CadastroAcervo.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new CadastroAcervo().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCancelarAcervo;
    private javax.swing.JButton btnLimparAcervo;
    private javax.swing.JButton btnOkLivro;
    private javax.swing.JComboBox cmbGeneroLivro;
    private javax.swing.JFormattedTextField idLivroAcervo;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel lblAcervoAviso;
    private javax.swing.JLabel lblAnoLivro;
    private javax.swing.JLabel lblAutorLivro;
    private javax.swing.JLabel lblAvisoIdLivro;
    private javax.swing.JLabel lblEditoraLivro;
    private javax.swing.JLabel lblGeneroLivro;
    private javax.swing.JLabel lblIdLivroAcervo;
    private javax.swing.JLabel lblNomeLivro;
    private javax.swing.JLabel lblSinopseLivro;
    private javax.swing.JEditorPane sinopseLivro;
    private javax.swing.JFormattedTextField txtAnoLivro;
    private javax.swing.JTextField txtAutorLivro;
    private javax.swing.JTextField txtEditoraLivro;
    private javax.swing.JTextField txtNomeLivro;
    // End of variables declaration//GEN-END:variables
}
